home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / COLRIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  6.7 KB  |  251 lines

  1. unit ColrImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib, ColorGrd;
  8.  
  9. type
  10.   TColorGridX = class(TActiveXControl, IColorGridX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TColorGrid;
  14.     FEvents: IColorGridXEvents;
  15.     procedure ChangeEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  18.   protected
  19.     { Protected declarations }
  20.     procedure InitializeControl; override;
  21.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     function Get_BackgroundColor: TColor; safecall;
  24.     function Get_BackgroundEnabled: WordBool; safecall;
  25.     function Get_BackgroundIndex: Integer; safecall;
  26.     function Get_ClickEnablesColor: WordBool; safecall;
  27.     function Get_Ctl3D: WordBool; safecall;
  28.     function Get_Cursor: Smallint; safecall;
  29.     function Get_DragCursor: Smallint; safecall;
  30.     function Get_Enabled: WordBool; safecall;
  31.     function Get_Font: Font; safecall;
  32.     function Get_ForegroundColor: TColor; safecall;
  33.     function Get_ForegroundEnabled: WordBool; safecall;
  34.     function Get_ForegroundIndex: Integer; safecall;
  35.     function Get_GridOrdering: TxGridOrdering; safecall;
  36.     function Get_Selection: Integer; safecall;
  37.     function Get_Visible: WordBool; safecall;
  38.     procedure AboutBox; safecall;
  39.     procedure Set_BackgroundEnabled(Value: WordBool); safecall;
  40.     procedure Set_BackgroundIndex(Value: Integer); safecall;
  41.     procedure Set_ClickEnablesColor(Value: WordBool); safecall;
  42.     procedure Set_Ctl3D(Value: WordBool); safecall;
  43.     procedure Set_Cursor(Value: Smallint); safecall;
  44.     procedure Set_DragCursor(Value: Smallint); safecall;
  45.     procedure Set_Enabled(Value: WordBool); safecall;
  46.     procedure Set_Font(const Value: Font); safecall;
  47.     procedure Set_ForegroundEnabled(Value: WordBool); safecall;
  48.     procedure Set_ForegroundIndex(Value: Integer); safecall;
  49.     procedure Set_GridOrdering(Value: TxGridOrdering); safecall;
  50.     procedure Set_Selection(Value: Integer); safecall;
  51.     procedure Set_Visible(Value: WordBool); safecall;
  52.   end;
  53.  
  54. implementation
  55. uses ColGrdPg;
  56. { TColorGridX }
  57.  
  58. procedure TColorGridX.InitializeControl;
  59. begin
  60.   FDelphiControl := Control as TColorGrid;
  61.   FDelphiControl.OnChange := ChangeEvent;
  62.   FDelphiControl.OnClick := ClickEvent;
  63.   FDelphiControl.OnKeyPress := KeyPressEvent;
  64. end;
  65.  
  66. procedure TColorGridX.EventSinkChanged(const EventSink: IUnknown);
  67. begin
  68.   FEvents := EventSink as IColorGridXEvents;
  69. end;
  70.  
  71. procedure TColorGridX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  72. begin
  73.   { Define property pages here.  Property pages are defined by calling
  74.     DefinePropertyPage with the class id of the page.  For example,
  75.       DefinePropertyPage(Class_ColorGridXPage); }
  76. end;
  77.  
  78. function TColorGridX.Get_BackgroundColor: TColor;
  79. begin
  80.   Result := FDelphiControl.BackgroundColor;
  81. end;
  82.  
  83. function TColorGridX.Get_BackgroundEnabled: WordBool;
  84. begin
  85.   Result := FDelphiControl.BackgroundEnabled;
  86. end;
  87.  
  88. function TColorGridX.Get_BackgroundIndex: Integer;
  89. begin
  90.   Result := FDelphiControl.BackgroundIndex;
  91. end;
  92.  
  93. function TColorGridX.Get_ClickEnablesColor: WordBool;
  94. begin
  95.   Result := FDelphiControl.ClickEnablesColor;
  96. end;
  97.  
  98. function TColorGridX.Get_Ctl3D: WordBool;
  99. begin
  100.   Result := FDelphiControl.Ctl3D;
  101. end;
  102.  
  103. function TColorGridX.Get_Cursor: Smallint;
  104. begin
  105.   Result := Smallint(FDelphiControl.Cursor);
  106. end;
  107.  
  108. function TColorGridX.Get_DragCursor: Smallint;
  109. begin
  110.   Result := Smallint(FDelphiControl.DragCursor);
  111. end;
  112.  
  113. function TColorGridX.Get_Enabled: WordBool;
  114. begin
  115.   Result := FDelphiControl.Enabled;
  116. end;
  117.  
  118. function TColorGridX.Get_Font: Font;
  119. begin
  120.   GetOleFont(FDelphiControl.Font, Result);
  121. end;
  122.  
  123. function TColorGridX.Get_ForegroundColor: TColor;
  124. begin
  125.   Result := FDelphiControl.ForegroundColor;
  126. end;
  127.  
  128. function TColorGridX.Get_ForegroundEnabled: WordBool;
  129. begin
  130.   Result := FDelphiControl.ForegroundEnabled;
  131. end;
  132.  
  133. function TColorGridX.Get_ForegroundIndex: Integer;
  134. begin
  135.   Result := FDelphiControl.ForegroundIndex;
  136. end;
  137.  
  138. function TColorGridX.Get_GridOrdering: TxGridOrdering;
  139. begin
  140.   Result := Ord(FDelphiControl.GridOrdering);
  141. end;
  142.  
  143. function TColorGridX.Get_Selection: Integer;
  144. begin
  145.   Result := FDelphiControl.Selection;
  146. end;
  147.  
  148. function TColorGridX.Get_Visible: WordBool;
  149. begin
  150.   Result := FDelphiControl.Visible;
  151. end;
  152.  
  153. procedure TColorGridX.AboutBox;
  154. begin
  155.   ShowColorGridXAbout;
  156. end;
  157.  
  158. procedure TColorGridX.Set_BackgroundEnabled(Value: WordBool);
  159. begin
  160.   FDelphiControl.BackgroundEnabled := Value;
  161. end;
  162.  
  163. procedure TColorGridX.Set_BackgroundIndex(Value: Integer);
  164. begin
  165.   FDelphiControl.BackgroundIndex := Value;
  166. end;
  167.  
  168. procedure TColorGridX.Set_ClickEnablesColor(Value: WordBool);
  169. begin
  170.   FDelphiControl.ClickEnablesColor := Value;
  171. end;
  172.  
  173. procedure TColorGridX.Set_Ctl3D(Value: WordBool);
  174. begin
  175.   FDelphiControl.Ctl3D := Value;
  176. end;
  177.  
  178. procedure TColorGridX.Set_Cursor(Value: Smallint);
  179. begin
  180.   FDelphiControl.Cursor := TCursor(Value);
  181. end;
  182.  
  183. procedure TColorGridX.Set_DragCursor(Value: Smallint);
  184. begin
  185.   FDelphiControl.DragCursor := TCursor(Value);
  186. end;
  187.  
  188. procedure TColorGridX.Set_Enabled(Value: WordBool);
  189. begin
  190.   FDelphiControl.Enabled := Value;
  191. end;
  192.  
  193. procedure TColorGridX.Set_Font(const Value: Font);
  194. begin
  195.   SetOleFont(FDelphiControl.Font, Value);
  196. end;
  197.  
  198. procedure TColorGridX.Set_ForegroundEnabled(Value: WordBool);
  199. begin
  200.   FDelphiControl.ForegroundEnabled := Value;
  201. end;
  202.  
  203. procedure TColorGridX.Set_ForegroundIndex(Value: Integer);
  204. begin
  205.   FDelphiControl.ForegroundIndex := Value;
  206. end;
  207.  
  208. procedure TColorGridX.Set_GridOrdering(Value: TxGridOrdering);
  209. begin
  210.   FDelphiControl.GridOrdering := TGridOrdering(Value);
  211. end;
  212.  
  213. procedure TColorGridX.Set_Selection(Value: Integer);
  214. begin
  215.   FDelphiControl.Selection := Value;
  216. end;
  217.  
  218. procedure TColorGridX.Set_Visible(Value: WordBool);
  219. begin
  220.   FDelphiControl.Visible := Value;
  221. end;
  222.  
  223. procedure TColorGridX.ChangeEvent(Sender: TObject);
  224. begin
  225.   if FEvents <> nil then FEvents.OnChange;
  226. end;
  227.  
  228. procedure TColorGridX.ClickEvent(Sender: TObject);
  229. begin
  230.   if FEvents <> nil then FEvents.OnClick;
  231. end;
  232.  
  233. procedure TColorGridX.KeyPressEvent(Sender: TObject; var Key: Char);
  234. var
  235.   TempKey: Smallint;
  236. begin
  237.   TempKey := Smallint(Key);
  238.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  239.   Key := Char(TempKey);
  240. end;
  241.  
  242. initialization
  243.   TActiveXControlFactory.Create(
  244.     ComServer,
  245.     TColorGridX,
  246.     TColorGrid,
  247.     Class_ColorGridX,
  248.     5,
  249.     '{5A56596F-7975-11D0-BE02-00A024D1875C}');
  250. end.
  251.